import request from '@/utils/request'

export function videos(query) {
  return request({
    url: '/video/index',
    method: 'GET',
    params: query
  })
}

export function update(data) {
  var params = new URLSearchParams()
  params.append('id', data.id)
  params.append('title', data.title)
  params.append('url', data.url)
  params.append('price', data.price)
  params.append('type', data.type)
  return request({
    url: '/video/' + data.id + '/update',
    method: 'put',
    params
  })
}

export function create(data) {
  var params = new URLSearchParams()
  params.append('id', data.id)
  params.append('title', data.title)
  params.append('url', data.url)
  params.append('price', data.price)
  params.append('type', data.type)
  return request({
    url: '/video/save',
    method: 'post',
    params
  })
}

export function remove(id) {
  return request({
    url: '/video/' + id + '/delete',
    method: 'delete'
  })
}
